//
//  IntegralMallVC.m
//  sensen_ios
//
//  Created by mc on 16/3/28.
//  Copyright © 2016年 pro. All rights reserved.
//

#import "IntegralMallVC.h"
#import "WebVC.h"
#import "WebViewController.h"
@interface IntegralMallVC ()

@end

@implementation IntegralMallVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"积分商城";
    self.view.backgroundColor = [UIColor whiteColor];
    // 创建导航栏左边返回按钮
    [self createLeftBarButtonItemWithImagename:nil];
    [self _initHeadView];
    
    // Do any additional setup after loading the view.
}

- (void)_initHeadView{
    
    UIView * head = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 70)];
    [self.view addSubview:head];
    
    UILabel * integralLable = [[UILabel alloc] init];
    [self.view addSubview:integralLable];
    integralLable.text = @"抽奖测试";
    integralLable.tag = 300;
    
    
    UILabel * earnLable = [[UILabel alloc] init];
    [self.view addSubview:earnLable];
    earnLable.text = @"如何赚取更多积分";
    earnLable.textColor = [UIColor lightGrayColor];
    earnLable.tag = 100;
    
    UILabel * recordLable = [[UILabel alloc] init];
    [self.view addSubview:recordLable];
    recordLable.text = @"积分兑换记录";
    recordLable.textColor = [UIColor lightGrayColor];
    recordLable.textAlignment = NSTextAlignmentRight;
    recordLable.tag = 200;
    [recordLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(head).offset(-10);
        make.centerY.equalTo(head).offset(-10);
        make.size.mas_equalTo(CGSizeMake(150, 20));
        
    }];
    
    [earnLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(head).offset(10);
        make.bottom.equalTo(head).offset(-10);
        make.size.mas_equalTo(CGSizeMake(150, 20));
    }];
    
    
    [integralLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(head).offset(10);
        make.top.equalTo(head).offset(10);
        make.size.mas_equalTo(CGSizeMake(150, 20));
    }];
    
    UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    [earnLable addGestureRecognizer:tap];
    UITapGestureRecognizer * tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    [recordLable addGestureRecognizer:tap2];
    earnLable.userInteractionEnabled = YES;
    recordLable.userInteractionEnabled = YES;
    
    UITapGestureRecognizer * tap3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    [integralLable addGestureRecognizer:tap3];
    integralLable.userInteractionEnabled = YES;

}



- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:YES];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
    // 设置导航栏颜色
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageWithColor:SS_NAVI_ORANGE_COLOR] forBarMetrics:UIBarMetricsDefault];
    // 隐藏标签栏
    MainTabBarController *main = (MainTabBarController *)self.navigationController.tabBarController;
    [main hideTabBar];
}



- (void)tapAction:(UITapGestureRecognizer *)tap{
    UserModel *user = [CommonCache getUserInfo];

    if (tap.view.tag == 100) {
        
        WebVC *vc = [[WebVC alloc] initWithUrlString:[NSString stringWithFormat:@"gainScore?uid=%@&psw=%@", user.uid, user.password]];
        vc.titleString = @"如何赚取积分";
        [self.navigationController pushViewController:vc animated:YES];
        
    }else if (tap.view.tag == 200){
        
        WebViewController *vc = [[WebViewController alloc] initWithUrlString:[NSString stringWithFormat:@"http://sunsun.itboye.com/index.php/Webview/Webview/ExchangeLog/index?uid=%@", user.uid]];
        vc.titleString = @"兑换记录";
        [self.navigationController pushViewController:vc animated:YES];
        
    }else if (tap.view.tag == 300){
    
         WebViewController *vc = [[WebViewController alloc] initWithUrlString:[NSString stringWithFormat:@"http://sunsun.itboye.com/index.php/Webview/Game/index?uid=%@&gid=3&psw=%@", user.uid, user.password]];
         vc.titleString = @"抽奖";
         [self.navigationController pushViewController:vc animated:YES];
    }


}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
